﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="MyUploads.aspx.cs" Inherits="FHost1.FormMyUploads" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        $(function () {
            $("#MainContent_btnCreateFolder").button();
            $("#MainContent_btnCancelFolder").button();
        });


        function ValidateFolderForm() {
            if (document.getElementById("<%=txtFolderName.ClientID %>").value == "") {
                alert("Enter folder name");
                return false;
            }

            return true;
        }
        function copyToClipboard(id) {
            var text = "http://fhost1.com/DownloadHandler.ashx?id=" + id;
            $("#dialog:ui-dialog").dialog("destroy");

            $("#dialog-modal").dialog({
                height: 140,
                modal: true
            });

            document.getElementById('dialog-modal').innerHTML = text;
        }

    </script>
   
    <div id="dialog-modal" style="font-size:12px;" title="Copy and share">
    </div>
    <asp:UpdatePanel ID="pnlUpdate" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <asp:Panel ID="pnlAddFolder" runat="server" Width="200px" CssClass="ui-widget ui-corner-all"
                Height="120px" Style="background-color: White; padding: 20px;">
                <label for="name">
                    Folder name</label>
                <asp:TextBox ID="txtFolderName" runat="server" CssClass="text ui-widget-content ui-corner-all"></asp:TextBox>
                <br />
                <br />
                <asp:Button ID="btnCancelFolder" Style="float: right; font-size: 13px;" runat="server"
                    Text="Cancel" />
                &nbsp;&nbsp;
                <asp:Button ID="btnCreateFolder" Style="float: right; font-size: 13px;" runat="server"
                    Text="Create" OnClientClick="return ValidateFolderForm();" OnClick="btnCreateFolder_Click" />
            </asp:Panel>
            <asp:ModalPopupExtender ID="pnlAddFolder_ModalPopupExtender" runat="server" DropShadow="true"
                BackgroundCssClass="modalBackground" DynamicServicePath="" Enabled="True" PopupControlID="pnlAddFolder"
                TargetControlID="btnAddFolder">
            </asp:ModalPopupExtender>
            <div style="margin: 50px;">
                <h2>
                    My Uploads...</h2>
                <hr />
                <table style="width: 100%;">
                    <tr>
                        <td>
                            <asp:ImageButton ID="btnAddFolder" ToolTip="Add folder" ImageUrl="~/images/Folder-Add-icon.png"
                                runat="server" />&nbsp;&nbsp;
                            <asp:ImageButton ID="btnUploadFile" ToolTip="Upload file" ImageUrl="~/images/Upload-icon.png"
                                runat="server" OnClick="btnUploadFile_Click" />&nbsp;&nbsp;
                            <asp:ImageButton ID="btnDelete" ToolTip="Delete folder/file" ImageUrl="~/images/delete-icon.png"
                                runat="server" OnClientClick="return confirm('Are you sure want to delete?');" />
                            &nbsp;&nbsp;<span style="font-size: 30px;">|</span>&nbsp;&nbsp;
                            <asp:ImageButton ID="btnGoUp" ToolTip="Go up..." ImageUrl="~/images/up-icon.png"
                                runat="server" OnClick="btnGoUp_Click" />
                            &nbsp;&nbsp;<span style="font-size: 30px;">|</span>&nbsp;&nbsp;
                            <asp:Label ID="lblSpaceStatus" runat="server" Text=""></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <br />
                            <asp:GridView ID="gridFolderFiles" runat="server" AutoGenerateColumns="False" Width="60%"
                                BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
                                CellPadding="3" OnRowDataBound="gridFolderFiles_RowDataBound">
                                <Columns>
                                    <asp:TemplateField ItemStyle-Width="30px">
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkSelect" UType='<%# DataBinder.Eval(Container.DataItem, "UType") %>'
                                                UID='<%# DataBinder.Eval(Container.DataItem, "ID") %>' runat="server" />
                                        </ItemTemplate>
                                        <ItemStyle Width="30px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Folder/File Name" ItemStyle-HorizontalAlign="Left">
                                        <ItemTemplate>
                                            <img src="images/<%# DataBinder.Eval(Container.DataItem, "UType") %>-icon.png" alt="item icon" />&nbsp;&nbsp;
                                            <asp:LinkButton ID="lnkFolderFile" runat="server" UType='<%# DataBinder.Eval(Container.DataItem, "UType") %>'
                                                UID='<%# DataBinder.Eval(Container.DataItem, "ID") %>' Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'
                                                OnClick="lnkFolderFile_Click" Visible="false"></asp:LinkButton>
                                            <asp:HyperLink Target="_blank" Visible="false" ID="hlFileLink" runat="server"><%# DataBinder.Eval(Container.DataItem, "Name") %></asp:HyperLink>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Left" />
                                    </asp:TemplateField>
                                    <asp:TemplateField ItemStyle-Width="30px" ItemStyle-HorizontalAlign="Center">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="btnDeleteSingle" UType='<%# DataBinder.Eval(Container.DataItem, "UType") %>'
                                                UID='<%# DataBinder.Eval(Container.DataItem, "ID") %>' runat="server" ImageUrl="~/images/delete-icon.png"
                                                Width="25px" OnClick="btnFileDelete_Click" OnClientClick="return confirm('Are you sure want to delete?')" />
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" Width="30px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <a href="#" onclick='copyToClipboard(<%# DataBinder.Eval(Container.DataItem, "ID") %>);'
                                                style="font-size: 12px;">Copy Link</a>
                                            <div id="divclipboardswf">
                                            </div>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" Width="70px" />
                                    </asp:TemplateField>
                                </Columns>
                                <EmptyDataTemplate>
                                    <span>No folder or files found! </span>
                                </EmptyDataTemplate>
                                <FooterStyle BackColor="White" ForeColor="#000066" />
                                <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                                <RowStyle ForeColor="#000066" />
                                <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                                <SortedAscendingHeaderStyle BackColor="#007DBB" />
                                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                                <SortedDescendingHeaderStyle BackColor="#00547E" />
                            </asp:GridView>
                        </td>
                    </tr>
                </table>
                <asp:HiddenField ID="hfCurrentFolder" runat="server" />
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
